<template>
    <div class="base-card">
        <div class="card-title">
            <div class="line" />
            <div class="pl-10px">
                <slot name="title">
                    {{ title }}
                </slot>
            </div>
        </div>
        <div class="card-content">
            <slot />
        </div>
        <div class="card-action" v-if="action">
            <el-button size="large" @click="cancleHandle">
                取消
            </el-button>
            <el-button type="primary" size="large" @click="submitHandle">
                提交
            </el-button>
        </div>
    </div>
</template>

<script setup>
defineProps({
    title: {
        type: String,
        default: ''
    },
    action: {
        type: Boolean,
        default: false
    }
})

const emits = defineEmits(['cancle', 'submit'])

const cancleHandle = () => {
    emits('cancle')
}
const submitHandle = () => {
    emits('submit')
}
</script>

<style lang="scss" scoped>
.base-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    background-color: #fff;
    box-shadow: 0 0 5px rgb(228 228 228 / 80%);

    .card-title {
        border-bottom: 1px solid #e9e9e9;
        padding: 10px;
        display: flex;
        align-items: center;
        height: 50px;
        color: #606266;

        .line {
            height: 70%;
            border-left: 4px solid #3d89f4;
            display: flex;
            align-items: center;
        }
    }

    .card-content {
        flex: 1;
        min-height: 0;
        width: 100%;
        padding: 10px;
    }

    .card-action {
        display: flex;
        justify-content: flex-end;
        padding: 20px 30px;
    }
}
</style>